package com.ceo.common.export;

import java.math.BigDecimal;
import java.sql.Time;
import java.sql.Timestamp;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;

public class DefaultFormater implements DataFormater
{
	private static DecimalFormat df=new DecimalFormat("0.00");
	private static SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
	private static SimpleDateFormat sdf2=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	private static SimpleDateFormat sdf3=new SimpleDateFormat("HH:mm:ss");
	public Object formater(Object obj)
	{
		if(obj==null)
			return "";
		else if(obj instanceof String)
			return obj.toString();
		else if(obj instanceof BigDecimal)
			return ((BigDecimal)obj).doubleValue();
		else if(obj instanceof java.sql.Date)
			return sdf.format(obj);
		else if(obj instanceof Timestamp)
			return sdf2.format(obj);
		else if(obj instanceof Time)
			return sdf3.format(obj);
		else if(obj instanceof java.util.Date)
			return sdf2.format(obj);
		else
			return obj;
	}

}
